<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page import="java.sql.*" %>
<html>
<head>
    <title>delete</title>
</head>
<body>
<%
    int curpage = 1;
    if (request.getParameter("page") != null) {
        String pg = request.getParameter("page");
        curpage = Integer.parseInt(pg);
    }
    String productCode = "";
    String productName = "";
    String productSize = "";
    String batch = "";
    String worker = "";
    String processingMethod = "";
    String processingDate = "";
    String workshop = "";
    String id = request.getParameter("id");

    if (request.getParameter("productCode") != null) productCode = request.getParameter("productCode");
    if (request.getParameter("productName") != null) productName = request.getParameter("productName");
    if (request.getParameter("productSize") != null) productSize = request.getParameter("productSize");
    if (request.getParameter("batch") != null) batch = request.getParameter("batch");
    if (request.getParameter("worker") != null) worker = request.getParameter("worker");
    if (request.getParameter("processingMethod") != null) processingMethod = request.getParameter("processingMethod");
    if (request.getParameter("processingDate") != null) processingDate = request.getParameter("processingDate");
    if (request.getParameter("workshop") != null) workshop = request.getParameter("workshop");

    Connection conn = (Connection)session.getAttribute("Connection");
    String sql = "delete from product where id=" + id;
    PreparedStatement preparedStatement = conn.prepareStatement(sql);
    int res = preparedStatement.executeUpdate();
    System.out.print(sql);
    if (res > 0) {
        out.println("删除数据成功");
        request.getRequestDispatcher("product_list.jsp").forward(request, response);
    } else {
        out.println("删除数据失败");
        response.setHeader("refresh", "3;product_list.jsp");
    }

%>
</body>
</html>
